-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Address book #229
[RFC] Address book #229
Conversation
Each of class misses empty line at the end of the file. Also, there are a few redundant comments. Did you think about using an Address VO from model namespace? |
Also, @jseparovic1 can you share your thoughts here or in Slack PM what are your experiences with working with ShopApiPlugin? Was it easy to add these endpoints? |
@lchrusciel we spoke with @pjedrzejewski and agree to not implement PATCH for updating as PUT is enough. Just to have in mind for reviewing code |
@antonioperic @jseparovic1 please ping me, when it will be ready for review. Or should I check it right now? |
@lchrusciel i need to finish unit tests, but you could check it right now, and let me know if there is something to change. |
@jseparovic1 would it be a problem for you to split this PR into smaller ones? |
spec/Command/UpdateAddressSpec.php
Outdated
use Sylius\ShopApiPlugin\Command\UpdateAddress; | ||
use Sylius\ShopApiPlugin\Model\Address; | ||
|
||
class UpdateAddressSpec extends ObjectBehavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of the specs are missing a final keyword
ProvinceInterface $province, | ||
FactoryInterface $addressFactory | ||
) { | ||
$tokenStorage->getToken()->willReturn($userToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to fetch the token inside a controller instead of the handler. It would decouple our logic from authorization mechanism, what is crucial if one would like to use an oauth for example. Or other open id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, i will refactor this. So i should fetch token inside a controller and pass it to related command and then in handler just get user from the token ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could even get a user in the controller and just add its email here. Security is a part of infrastructure
at the end. And even if I didn't introduce proper namespace separation(yet ;)) we could try to follow that rule, I suppose. What's your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so i will get user from token , and pass its email to a command. The in the handler i will resolve user from email. This sounds nice to me and i agree that getting user from token in handler is really bad idea because of tightly coupling. I have few more situations with getting current user, so I want to be sure it is done in proper way.
src/Command/UpdateAddress.php
Outdated
private $address; | ||
|
||
/** | ||
* CreateAddress constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments are redundant. There are at least 6 more to delete.
@@ -0,0 +1,105 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to refactor the plugin to introduce it in the whole codebase... Just a side note
@lchrusciel I refactored this like we agreed. Unfortunately I don't have time right now for splitting up this into smaller PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good to merge, but rebase is needed.
src/Model/Address.php
Outdated
* | ||
* @return Address | ||
*/ | ||
public static function createFromRequest(Request $request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return type
The tests are failing... :( |
@jseparovic1 Hi! Do you guys plan to update this PR? :) |
@pjedrzejewski Hi, i plan to update it in upcoming weeks. Since we have tight project deadline I decide to customize this feature for our needs and finish PR later :) |
@jseparovic1 are you adjusting forked code or used a custom implementation? I'm just wondering how it will work in such a case. Also, sorry for long feedback loops. |
@lchrusciel forked code remains the same, i created new classes under my project namespace. It should work like a charm :) |
I would love to merge it, but we need tests to pass to do it. :( |
@lchrusciel I installed php 7.2 and found an error so text are now fixed. PR should be ready now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for all your work! I hope you enjoyed working with the plugin. Most of my comments are just some small changes but for example, better validation message is pretty important. Will you find some time to fix the PR?
src/Command/RemoveAddress.php
Outdated
|
||
namespace Sylius\ShopApiPlugin\Command; | ||
|
||
class RemoveAddress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing final
} | ||
|
||
/** @var ShopUserInterface $shopUser */ | ||
$shopUser = $this->tokenStorage->getToken()->getUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert::isInstanceOf($user, ShopUserInterface::class);
This would be a great feature to have. |
Woah, I hope I got rebasing right 🎉 |
Thank you, Jurica! |
|
GET /address-book
POST /address-book
PUT /address-book/{id}
DELETE /address-book/{id}
PATCH /address-book/{id}/default
Add tests
Add translation labels